package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.commons.result.ServiceCallResponse;
import com.cskaoyan.shopping.converter.ContentConverter;
import com.cskaoyan.shopping.converter.ProductCateConverter;
import com.cskaoyan.shopping.dal.entitys.ItemCat;
import com.cskaoyan.shopping.dal.entitys.Panel;
import com.cskaoyan.shopping.dal.entitys.PanelContent;
import com.cskaoyan.shopping.dal.entitys.PanelContentItem;
import com.cskaoyan.shopping.dal.persistence.ItemCatMapper;
import com.cskaoyan.shopping.dal.persistence.PanelContentMapper;
import com.cskaoyan.shopping.dal.persistence.PanelMapper;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelContentItemDto;
import com.cskaoyan.shopping.dto.PanelDto;

import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.service.IContentService;
import com.cskaoyan.shopping.service.IHomeService;
import com.cskaoyan.shopping.service.IProductCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

/**
 * TODO
 *
 * @param
 * @author wj
 * @return
 */
@RestController
@RequestMapping("shopping")
public class WjShoppingController {
    @Autowired
    IHomeService iHomeService;
    @Autowired
    IContentService iContentService;
    @Autowired
    IProductCateService iProductCateService;
    @GetMapping("homepage")
    public ResponseData homepage(){
        //封装板块
        Set<PanelDto> homepage = iHomeService.homepage();
        ResponseUtil<Set<PanelDto>> responseUtil = new ResponseUtil<>();
        ResponseData responseData = responseUtil.setData(homepage);

        return responseData;
    }
    @GetMapping("navigation")
    public ResponseData navigation(){
        List<PanelContentDto> panelContentDtos = iContentService.queryNavList();
        ResponseUtil<List<PanelContentDto>> responseUtil = new ResponseUtil<>();
        ResponseData responseData = responseUtil.setData(panelContentDtos);
        return responseData;
    }
    @GetMapping("categories")
    public ResponseData categories(){
        List<ProductCateDto> allProductCate = iProductCateService.getAllProductCate("desc");
        ResponseUtil<List<ProductCateDto>> responseUtil = new ResponseUtil<>();
        ResponseData responseData = responseUtil.setData(allProductCate);
        return responseData;
    }

}
